using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Threading;

namespace ImportSubscriber
{
    public class Log
    {
        #region Send Log Info to form

        private static frmMain m_form = null;
        public static frmMain SetForm(frmMain form)
        {
            m_form = form;
            return m_form;
        }

        private delegate void delegate_WriteLog(Color color, string s, bool log_to_window, bool log_to_file);
        public static void Write(Color color, string s, bool log_to_window, bool log_to_file)
        {
            try
            {
                if ((m_form != null) && m_form.Created)
                    m_form.Invoke(new delegate_WriteLog(m_form.WriteLogImplement), new object[] { color, s, log_to_window, log_to_file });
            }
            catch
            {
            }
        }

        public static void Write(Color color, string s)
        {
            Write(color, s, true, true);
        }

        public static void Write(Color color, string format, params object[] objects)
        {
            Write(color, String.Format(format, objects), true, true);
        }

        public static void Write(string s)
        {
            Write(Color.Black, s, true, true);
        }

        public static void Write(string format, params object[] objects)
        {
            Write(Color.Black, String.Format(format, objects), true, true);
        }

        public static void WriteToFile(string s)
        {
            Write(Color.Black, s, false, true);
        }

        public static void WriteToFile(string format, params object[] objects)
        {
            Write(Color.Black, String.Format(format, objects), false, true);
        }

        #endregion
    }
}
